// Load multiple forms in one modal using Ajax
$(document).on('eldarion-ajax:success', '._modal.ajax', function(ent, $el, data){
	$('.modal-content').empty();
	$(data.responseText).appendTo('.modal-content');
	$('#myModal').modal('show');
});

$(document).on('eldarion-ajax:success', 'form.ajax', function(ent, $el, data){
	$("#myModal").modal("hide");
	location.reload(false);
});


$(document).on('eldarion-ajax:error', 'form.ajax', function(ent, $el, data){
	alert('Error!');
});


$(document).on('eldarion-ajax:success', '.silent.ajax', function(ent, $el, data){
	location.reload(false);
});

// Creating and deleting of the CKEDITOR - Work only with one element
$('#myModal').on('shown.bs.modal', function(e){
	if (!CKEDITOR.myInstance){
		CKEDITOR.myInstance = CKEDITOR.replace($('textarea')[0]);
	}
});
$('#myModal').on('hidden.bs.modal', function(e){
	if (CKEDITOR.myInstance){
		CKEDITOR.myInstance.destroy();
		delete CKEDITOR.myInstance;
	}
});

$(document).ready(function(){
	// Enable buttons after full loading of page
	$('a.btn').removeClass('disabled');
});